# coding=utf-8
import re

# 反斜杠作为转义
s = "\n123"
print(s)
s = "\\n123"
print(s)
# 使用原生字符串 r
s = r"\n123"
print(s)
# 在正则表达式中反斜杠作为转义
s = "\n123"
partten = "\\n\d{3}"
print(re.match(partten, s))
# 目标字符串多个反斜杠
s = "\\n123"
partten = "\\\\n\d{3}"
print(re.match(partten, s))
# 使用原生字符串 r
s = "\\\\n123"
partten = r"\\\\n\d{3}"
print(re.match(partten, s))
